package com.buba.service.impl;

import com.buba.dao.RoomTypeMapper;
import com.buba.pojo.RoomType;
import com.buba.service.RoomTypeService;
import com.buba.vo.RoomTypeVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class RoomTypeServiceImpl implements RoomTypeService {
    @Resource
    private RoomTypeMapper roomTypeMapper;


    /**
     * todo 查询所有房源
     * @param roomTypeVO
     * @return
     */
    public List<RoomType> findRoomTypeList(RoomTypeVO roomTypeVO) {
        return roomTypeMapper.findRoomTypeList(roomTypeVO);
    }
    /**
     * todo 添加房型
     * @param roomType
     * @return
     */
    public int addRoomType(RoomType roomType) {

        //可用房间数默认是全部的房间数量
        roomType.setAvilablenum(roomType.getRoomnum());
        //已入住房间数量
        roomType.setLivednum(0);
        return roomTypeMapper.addRoomType(roomType);
    }

    /**
     * todo 修改房型
     * @param roomType
     * @return
     */
    public int updateRoomType(RoomType roomType) {
        //可用房间数默认是全部的房间数量
        roomType.setAvilablenum(roomType.getRoomnum());
        //已入住房间数量
        roomType.setLivednum(0);

        return roomTypeMapper.updateRoomType(roomType);
    }

    @Override
    public int deleteById(int id) {
        return roomTypeMapper.deleteById(id);
    }


}

